package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookAuthor;
import com.pgybook.db.entity.domain.BookAuthorEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookAuthorMapper {
    int countByExample(BookAuthorEx example);

    int deleteByExample(BookAuthorEx example);

    @Delete({
            "delete from bookauthor",
            "where AUTHORID = #{authorid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer authorid);

    @Insert({
            "insert into bookauthor (NAME, GENDER, ",
            "CHINESE, COUNTRY, DESCRIPTION, ",
            "STATUS, CRTTIME, ",
            "CRTSTAFF, UPDTIME, ",
            "UPDSTAFF)",
            "values (#{name,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR}, ",
            "#{chinese,jdbcType=BIT}, #{country,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, ",
            "#{status,jdbcType=INTEGER}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{crtstaff,jdbcType=INTEGER}, #{updtime,jdbcType=TIMESTAMP}, ",
            "#{updstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "authorid", before = false, resultType = Integer.class)
    int insert(BookAuthor record);

    int insertSelective(BookAuthor record);

    List<BookAuthor> selectByExample(BookAuthorEx example);

    @Select({
            "select",
            "AUTHORID, NAME, GENDER, CHINESE, COUNTRY, DESCRIPTION, STATUS, CRTTIME, CRTSTAFF, ",
            "UPDTIME, UPDSTAFF",
            "from bookauthor",
            "where AUTHORID = #{authorid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    BookAuthor selectByPrimaryKey(Integer authorid);

    int updateByExampleSelective(@Param("record") BookAuthor record, @Param("example") BookAuthorEx example);

    int updateByExample(@Param("record") BookAuthor record, @Param("example") BookAuthorEx example);

    int updateByPrimaryKeySelective(BookAuthor record);

    @Update({
            "update bookauthor",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "GENDER = #{gender,jdbcType=CHAR},",
            "CHINESE = #{chinese,jdbcType=BIT},",
            "COUNTRY = #{country,jdbcType=VARCHAR},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER}",
            "where AUTHORID = #{authorid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BookAuthor record);
}
